home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Gekkan Dennou Club 147
/
Gekkan Dennou Club - 2000.8 Vol. 147 (Japan).7z
/
Gekkan Dennou Club - 2000.8 Vol. 147 (Japan) (Track 1).bin
/
games
/
ippon
/
source.lzh
/
FuncEnemy
/
sword.c
< prev
next >
Wrap
C/C++ Source or Header
|
2000-07-07
|
6KB
|
237 lines
/* sword.c 剣みたいに長い敵 */
#include <xsp2lib.h>
#include "../main.h"
#include "../player.h"
#include "../shot.h"
#include "../enemy.h"
#include "../eshot.h"
#include "../effect.h"
#include "../psearch.h"
#include "../sound.h"
#define PALET_MAIN 0x0400
#define HP_0 90
enum {
APPEAR_LEFT = 0, APPEAR_RIGHT
};
#define wabs(x) ((x) >= 0 ? (short) (x) : (short) -(x))
/* 関数プロトタイプ宣言 */
static short EnemyMoveSword (ENEMY *);
static void EnemyFreeSword (ENEMY *);
/* 初期化ルーチン */
void EnemyAllocSword (ENEMY * p)
{
if (SHORT_LX < 144) {
p->m_work5 = APPEAR_LEFT;
p->vx = 32768;
} else {
p->m_work5 = APPEAR_RIGHT;
p->vx = -32768;
}
p->vy = 65536;
p->pt = obj_sword;
p->info = PALET_MAIN | PRIORITY_BOSS;
p->hit_sx = 48; /* 自機ショットに対する当たり判定 */
p->hit_sy = 16;
p->hp = HP_0;
p->damage = 0;
p->flash = 0;
p->damage_mode = DAMAGE_PIERCE;
p->func_enemy_move = EnemyMoveSword;
p->func_enemy_free = EnemyFreeSword;
/* コア関連 */
p->core_info = PALET_CORE_BLUE | PRIORITY_BOSS;
p->core_pt = sp_core;
p->m_work = p->m_work2 = p->s_work = 0;
}
/* 移動ルーチン */
/* 返り値:非0なら消去 */
static short EnemyMoveSword (ENEMY * p)
{
/* 速度を足して上位ワード(固定整数部)だけ取り出す */
p->x = (p->lx += p->vx) >> 16;
p->y = (p->ly += p->vy) >> 16;
switch (p->m_work) {
case 0:
if (p->m_work2++ > 150) {
if (p->m_work5 == APPEAR_LEFT) {
if ((p->vx -= 2048) <= 0)
p->m_work++;
} else {
if ((p->vx += 2048) >= 0)
p->m_work++;
}
}
/* 攻撃処理 */
#define INTERVAL0_START 100
#define INTERVAL0 65
#define SPEED_SHOT0 10
switch (p->s_work++) {
case INTERVAL0_START + INTERVAL0 * 0:
case INTERVAL0_START + INTERVAL0 * 1:
EshotAlloc (ESHOT_NRG05, p->x, p->y + 16, SPEED_SHOT0, 64, 1);
EshotAlloc (ESHOT_NRG04, p->x - 6, p->y + 8, SPEED_SHOT0, 64, 1);
EshotAlloc (ESHOT_NRG04, p->x + 6, p->y + 8, SPEED_SHOT0, 64, 1);
EshotAlloc (ESHOT_NRG03, p->x - 12, p->y, SPEED_SHOT0, 64, 1);
EshotAlloc (ESHOT_NRG03, p->x + 12, p->y, SPEED_SHOT0, 64, 1);
SoundSetSE (SE_ESHOT_M); /* 敵ショット音 */
break;
case INTERVAL0_START + INTERVAL0 * 2:
p->s_work = 0;
break;
default:
break;
}
break;
case 1:
if (p->vy > -8192) {
p->vy -= 2048;
} else {
p->m_work++;
}
break;
/* カバー開く */
case 2:
p->pt++;
if (p->pt >= obj_sword + 24) { /* カバー開ききったら */
p->m_work++;
p->s_work = p->s_work2 = p->s_work3 = 0;
SoundSetSE (SE_LOCK_M);
}
break;
case 3:
if (p->vy < 16384)
p->vy += 2048;
/* 攻撃処理 */
switch (p->s_work2++) {
#define INTERVAL1_1 20
#define SPEED_SHOT1_1 6
case INTERVAL1_1 * 1:
p->s_angle = psearch (p->x - 16, p->y - 8) - 4; /* 自機の方向をサーチ */
p->s_angle2 = psearch (p->x + 16, p->y - 8) + 4; /* 自機の方向をサーチ */
EshotAlloc (ESHOT_NRG24N, p->x - 16, p->y - 8, SPEED_SHOT1_1, p->s_angle, 0);
EshotAlloc (ESHOT_NRG24N, p->x + 16, p->y - 8, SPEED_SHOT1_1, p->s_angle2, 0);
SoundSetSE (SE_ESHOT_M); /* 敵ショット音 */
break;
case INTERVAL1_1 * 2:
case INTERVAL1_1 * 3:
case INTERVAL1_1 * 4:
EshotAlloc (ESHOT_NRG14N, p->x - 16, p->y - 8, SPEED_SHOT1_1, p->s_angle + 4, 0);
EshotAlloc (ESHOT_NRG14N, p->x + 16, p->y - 8, SPEED_SHOT1_1, p->s_angle2, 0);
SoundSetSE (SE_ESHOT_M); /* 敵ショット音 */
break;
case INTERVAL1_1 * 7:
p->s_work2 = 0;
break;
}
/* 下向き矢印弾 */
#define INTERVAL1_2 28
#define SPEED_SHOT1_2 10
switch (p->s_work3++) {
case INTERVAL1_2 * 1:
if (wabs (SHORT_LX - player->x) < 64) {
EshotAlloc (ESHOT_NRG05, p->x, p->y + 16, SPEED_SHOT0, 64, 1);
EshotAlloc (ESHOT_NRG04, p->x - 6, p->y + 8, SPEED_SHOT0, 64, 1);
EshotAlloc (ESHOT_NRG04, p->x + 6, p->y + 8, SPEED_SHOT0, 64, 1);
EshotAlloc (ESHOT_NRG03, p->x - 12, p->y, SPEED_SHOT0, 64, 1);
EshotAlloc (ESHOT_NRG03, p->x + 12, p->y, SPEED_SHOT0, 64, 1);
SoundSetSE (SE_ESHOT_M); /* 敵ショット音 */
}
break;
case INTERVAL1_2 * 6:
p->s_work3 = 0;
break;
}
if (SHORT_LY > 192)
p->m_work++;
break;
/* 撤退 */
case 4:
if (SHORT_VY < 1)
p->vy += 4096;
/* 画面外に出たら消去 */
if (SHORT_LY > 256 + 64 + 16)
return (-1); /* 消去 */
break;
}
/* もし前回ダメージを受けたなら */
if (p->damage) {
p->hp -= p->damage;
p->damage = 0;
SoundSetSE (SE_DAMAGE); /* 敵ダメージ音 */
/* 白(or赤)フラッシュ処理 */
if (p->info == (PALET_MAIN | PRIORITY_BOSS)) {
if (p->hp < HP_PALET_RED)
p->info = PALET_RED | PRIORITY_BOSS;
else
p->info = PALET_DAMAGE | PRIORITY_BOSS;
} else {
p->info = PALET_MAIN | PRIORITY_BOSS;
}
/* 耐久力が0以下なら消去 */
if (p->hp <= 0) {
EffectAlloc (EFFECT_EXPL, 0, p->x, p->y); /* 爆発パターンを出現させる */
EffectAlloc (EFFECT_POINTS, POINTS_3000, p->x, p->y); /* 得点を出現させる */
SoundSetSE (SE_EXPL_M); /* 中ボス爆発音 */
return (-1);
}
} else {
/* 耐久力が少なくなったら赤フラッシュ */
if ((p->flash++ > TIMER_FLASH_RED) && (p->hp < HP_PALET_RED)) {
p->info = PALET_RED | PRIORITY_BOSS;
if (p->flash > TIMER_FLASH_NORMAL)
p->flash = 0;
} else {
p->info = PALET_MAIN | PRIORITY_BOSS;
}
}
xobj_set_st (p); /* 表示 */
/* コアの表示 */
p->core_x = p->x - 8;
p->core_y = p->y - 8;
xsp_set_st (&(p->core_x));
return (0);
}
/* 消去ルーチン */
static void EnemyFreeSword (ENEMY * p)
{
/* 刺さったショットの処理 */
if ((p->shot) && (p->shot->enemy) && (p->shot->enemy == p))
p->shot->status = SHOT_STATUS_NON;
}